package com.lanbu.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.lanbu.common.core.controller.BaseController;
import com.lanbu.common.core.domain.AjaxResult;
import com.lanbu.common.core.page.TableDataInfo;
import com.lanbu.common.enums.BusinessType;
import com.lanbu.common.utils.poi.ExcelUtil;
import com.lanbu.system.domain.SysReviewUser;
import com.lanbu.system.service.ISysDeptService;
import com.lanbu.system.service.ISysReviewUserService;
import com.lanbu.common.annotation.Log;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户信息Controller
 *
 * @author ruoyi
 * @date 2024-09-23
 */
@RestController
@RequestMapping("/system/review")
public class SysReviewUserController extends BaseController {
    @Autowired
    private ISysReviewUserService sysReviewUserService;
    @Autowired
    private ISysDeptService deptService;

    /**
     * 查询用户信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:review:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysReviewUser sysReviewUser) {
        startPage();
        List<SysReviewUser> list = sysReviewUserService.selectSysReviewUserList(sysReviewUser);
        return getDataTable(list);
    }

    /**
     * 导出用户信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:review:export')")
    @Log(title = "用户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysReviewUser sysReviewUser) {
        List<SysReviewUser> list = sysReviewUserService.selectSysReviewUserList(sysReviewUser);
        ExcelUtil<SysReviewUser> util = new ExcelUtil<SysReviewUser>(SysReviewUser.class);
        util.exportExcel(response, list, "用户信息数据");
    }

    /**
     * 获取用户信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:review:query')")
    @GetMapping(value = "/{applicantId}")
    public AjaxResult getInfo(@PathVariable("applicantId") Long applicantId) {
        return success(sysReviewUserService.selectSysReviewUserByApplicantId(applicantId));
    }

    /**
     * 新增用户信息
     */
    @PreAuthorize("@ss.hasPermi('system:review:add')")
    @Log(title = "用户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysReviewUser sysReviewUser) {
        return toAjax(sysReviewUserService.insertSysReviewUser(sysReviewUser));
    }


    /**
     * 审核用户信息
     */
    @PreAuthorize("@ss.hasPermi('system:review:examine')")
    @Log(title = "审核用户", businessType = BusinessType.INSERT)
    @PostMapping("/examine")
    public AjaxResult examine(@RequestBody SysReviewUser sysReviewUser) {
        deptService.checkDeptDataScope(sysReviewUser.getDeptId());
        return toAjax(sysReviewUserService.examineSysReviewUser(sysReviewUser));
    }

    /**
     * 修改用户信息
     */
    @PreAuthorize("@ss.hasPermi('system:review:edit')")
    @Log(title = "用户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysReviewUser sysReviewUser) {
        return toAjax(sysReviewUserService.updateSysReviewUser(sysReviewUser));
    }

    /**
     * 删除用户信息
     */
    @PreAuthorize("@ss.hasPermi('system:review:remove')")
    @Log(title = "用户信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{applicantIds}")
    public AjaxResult remove(@PathVariable Long[] applicantIds) {
        return toAjax(sysReviewUserService.deleteSysReviewUserByApplicantIds(applicantIds));
    }


}
